Event.observe ( window, 'load', bootstrap );

/*var updater_id = new Ajax.PeriodicalUpdater ( 'isock_universe', '/admin/sessions?auto_refresh=1', {
  method     : 'get',
  frequency  : 10,
  decay      : 1,
  onComplete : function ( transport ) {}
} );*/

function bootstrap () {
  $( 'sessions_all'  ).on ( 'click', sessions_all  );
  $( 'sessions_none' ).on ( 'click', sessions_none );
  
/*alter_auto_refresh ();*/
}

function sessions_all () {
  $$( 'input[type="checkbox"][name]' ).each ( function ( node ) { node.checked = true  } );
}

function sessions_none () {
  $$( 'input[type="checkbox"][name]' ).each ( function ( node ) { node.checked = false } );
}

function alter_auto_refresh () {
  if ( $( 'auto_refresh' ).checked ) {
    updater_id.start ();
  }
  else {
    updater_id.stop  ();
  }
}
